<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="d1" >

    </div>
    <script>
        var div = document.querySelector('div');
        console.log(div.getAttribute('id'));

        //设置元素属性
        console.log(div.setAttribute('class','index'));//只是设置了他的属性值，并没有得到打印它的值

        //删除元素属性
        console.log(div.removeAttribute('class'));
        


    </script>
</body>
</html>